package base.多线程.扩展JUC.原子类;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

public class Original extends Thread {
        /*测试原子类使用*/


    static volatile int count = 0;
    static Object obj = new Object();
    static AtomicInteger ato = new AtomicInteger(0);

    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            ato.incrementAndGet();
        }
    }
}

class Test1 {
    public static void main(String[] args) throws InterruptedException {

        for (int i = 0; i < 100; i++) {

            new Original().start();

        }
        TimeUnit.SECONDS.sleep(4);
        System.out.println(Original.ato.get());

    }
}
